package com.spa.common.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.spa.common.api.vo.Result;

import cn.dev33.satoken.util.SaResult;

//@RestControllerAdvice
public class GlobalExceptionHandler {

    // 全局异常拦截
    @ExceptionHandler
    public Result<?> handlerException(Exception e) {
        e.printStackTrace();
        String message = e.getMessage();
        int i = e.getMessage().indexOf("无此权限");
        if(e.getMessage().indexOf("无此权限") > -1) {
            return Result.error(403, "无此权限:请联系管理员！");
        }
        return Result.error(200, "");
    }
}
